import Vue from 'vue'
import VueRouter from "vue-router"

Vue.use(VueRouter)

// 创建一个路由器实例，并且配置路由规则
const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes: [
        {
            path: '/',
            name: 'home',
            component: () => import('../views/home.vue')
        },
        {
            path: '/c/:category',
            name: 'category',
            component: () => import('../views/home.vue')
        },
        {
            path: '/p/:listId',
            name: 'playlist',
            component: () => import('../views/playlist.vue')
        },
        {
            path: '/s',
            name: 'search',
            component: () => import('../views/search.vue'),
            props: (route) => ({ query: route.query.q })
        },
        {
            path: '/about',
            component: () => import('../views/about.vue')
        },
        {
            path: '/login',
            component: () => import('../views/login.vue')
        }
    ]
})

export default router